home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Terminals.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  15KB  |  406 lines

  1. /*
  2.      File:        Terminals.h
  3.  
  4.      Contains:    Communications Toolbox Terminal tool Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __TERMINALS__
  19. #define __TERMINALS__
  20.  
  21. #ifndef __DIALOGS__
  22. #include <Dialogs.h>
  23. #endif
  24. #ifndef __CTBUTILITIES__
  25. #include <CTBUtilities.h>
  26. #endif
  27. #ifndef __CONNECTIONS__
  28. #include <Connections.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT_SUPPORTED
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_ALIGN_SUPPORTED
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. #if FOR_SYSTEM7_ONLY
  44.  
  45. enum {
  46.                                                                 /* current Terminal Manager version     */
  47.     curTMVersion                = 2,                            /* current Terminal Manager Environment Record version     */
  48.     curTermEnvRecVers            = 0,                            /* error codes    */
  49.     tmGenericError                = -1,
  50.     tmNoErr                        = 0,
  51.     tmNotSent                    = 1,
  52.     tmEnvironsChanged            = 2,
  53.     tmNotSupported                = 7,
  54.     tmNoTools                    = 8
  55. };
  56.  
  57. typedef OSErr TMErr;
  58.  
  59. enum {
  60.     tmInvisible                    = 1 << 0,
  61.     tmSaveBeforeClear            = 1 << 1,
  62.     tmNoMenus                    = 1 << 2,
  63.     tmAutoScroll                = 1 << 3,
  64.     tmConfigChanged                = 1 << 4
  65. };
  66.  
  67. typedef unsigned long TMFlags;
  68.  
  69. enum {
  70.     selTextNormal                = 1 << 0,
  71.     selTextBoxed                = 1 << 1,
  72.     selGraphicsMarquee            = 1 << 2,
  73.     selGraphicsLasso            = 1 << 3,
  74.     tmSearchNoDiacrit            = 1 << 8,
  75.     tmSearchNoCase                = 1 << 9
  76. };
  77.  
  78. typedef unsigned short TMSearchTypes;
  79. typedef short TMSelTypes;
  80.  
  81. enum {
  82.     cursorText                    = 1,
  83.     cursorGraphics                = 2
  84. };
  85.  
  86. typedef unsigned short TMCursorTypes;
  87.  
  88. enum {
  89.     tmTextTerminal                = 1 << 0,
  90.     tmGraphicsTerminal            = 1 << 1
  91. };
  92.  
  93. typedef unsigned short TMTermTypes;
  94. struct TermDataBlock {
  95.     TMTermTypes                     flags;
  96.     Handle                             theData;
  97.     Handle                             auxData;
  98.     long                             reserved;
  99. };
  100. typedef struct TermDataBlock TermDataBlock;
  101.  
  102. typedef TermDataBlock *TermDataBlockPtr;
  103. typedef TermDataBlockPtr *TermDataBlockH;
  104. typedef TermDataBlockPtr *TermDataBlockHandle;
  105. struct TermEnvironRec {
  106.     short                             version;
  107.     TMTermTypes                     termType;
  108.     short                             textRows;
  109.     short                             textCols;
  110.     Point                             cellSize;
  111.     Rect                             graphicSize;
  112.     Point                             slop;
  113.     Rect                             auxSpace;
  114. };
  115. typedef struct TermEnvironRec TermEnvironRec;
  116.  
  117. typedef TermEnvironRec *TermEnvironPtr;
  118. union TMSelection {
  119.     Rect                             selRect;
  120.     RgnHandle                         selRgnHandle;
  121. };
  122. typedef union TMSelection TMSelection;
  123.  
  124. typedef struct TermRecord TermRecord;
  125. typedef TermRecord *TermPtr;
  126. typedef TermPtr *TermHandle;
  127. typedef pascal long (*TerminalSendProcPtr)(Ptr thePtr, long theSize, long refCon, CMFlags flags);
  128. typedef pascal void (*TerminalBreakProcPtr)(long duration, long refCon);
  129. typedef pascal long (*TerminalCacheProcPtr)(long refCon, TermDataBlockPtr theTermData);
  130. typedef pascal void (*TerminalSearchCallBackProcPtr)(TermHandle hTerm, short refNum, Rect *foundRect);
  131. typedef pascal Boolean (*TerminalClikLoopProcPtr)(long refCon);
  132. typedef pascal CMErr (*TerminalEnvironsProcPtr)(long refCon, TermEnvironRec *theEnvirons);
  133. typedef pascal void (*TerminalChooseIdleProcPtr)(void );
  134. typedef pascal long (*TerminalToolDefProcPtr)(TermHandle hTerm, short msg, long p1, long p2, long p3);
  135.  
  136. #if GENERATINGCFM
  137. typedef UniversalProcPtr TerminalSendUPP;
  138. typedef UniversalProcPtr TerminalBreakUPP;
  139. typedef UniversalProcPtr TerminalCacheUPP;
  140. typedef UniversalProcPtr TerminalSearchCallBackUPP;
  141. typedef UniversalProcPtr TerminalClikLoopUPP;
  142. typedef UniversalProcPtr TerminalEnvironsUPP;
  143. typedef UniversalProcPtr TerminalChooseIdleUPP;
  144. typedef UniversalProcPtr TerminalToolDefUPP;
  145. #else
  146. typedef TerminalSendProcPtr TerminalSendUPP;
  147. typedef TerminalBreakProcPtr TerminalBreakUPP;
  148. typedef TerminalCacheProcPtr TerminalCacheUPP;
  149. typedef TerminalSearchCallBackProcPtr TerminalSearchCallBackUPP;
  150. typedef TerminalClikLoopProcPtr TerminalClikLoopUPP;
  151. typedef TerminalEnvironsProcPtr TerminalEnvironsUPP;
  152. typedef TerminalChooseIdleProcPtr TerminalChooseIdleUPP;
  153. typedef TerminalToolDefProcPtr TerminalToolDefUPP;
  154. #endif
  155. /*    TMTermTypes     */
  156. struct TermRecord {
  157.     short                             procID;
  158.     TMFlags                         flags;
  159.     TMErr                             errCode;
  160.     long                             refCon;
  161.     long                             userData;
  162.     TerminalToolDefUPP                 defProc;
  163.     Ptr                             config;
  164.     Ptr                             oldConfig;
  165.     TerminalEnvironsUPP             environsProc;
  166.     long                             reserved1;
  167.     long                             reserved2;
  168.     Ptr                             tmPrivate;
  169.     TerminalSendUPP                 sendProc;
  170.     TerminalBreakUPP                 breakProc;
  171.     TerminalCacheUPP                 cacheProc;
  172.     TerminalClikLoopUPP             clikLoop;
  173.     WindowPtr                         owner;
  174.     Rect                             termRect;
  175.     Rect                             viewRect;
  176.     Rect                             visRect;
  177.     long                             lastIdle;
  178.     TMSelection                     selection;
  179.     TMSelTypes                         selType;
  180.     long                             mluField;
  181. };
  182.  
  183.  
  184. enum {
  185.     uppTerminalSendProcInfo = kPascalStackBased
  186.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  187.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  188.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  189.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  190.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMFlags))),
  191.     uppTerminalBreakProcInfo = kPascalStackBased
  192.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  193.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))),
  194.     uppTerminalCacheProcInfo = kPascalStackBased
  195.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  196.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  197.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(TermDataBlockPtr))),
  198.     uppTerminalSearchCallBackProcInfo = kPascalStackBased
  199.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(TermHandle)))
  200.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  201.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Rect *))),
  202.     uppTerminalClikLoopProcInfo = kPascalStackBased
  203.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  204.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))),
  205.     uppTerminalEnvironsProcInfo = kPascalStackBased
  206.          | RESULT_SIZE(SIZE_CODE(sizeof(CMErr)))
  207.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  208.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(TermEnvironRec *))),
  209.     uppTerminalChooseIdleProcInfo = kPascalStackBased,
  210.     uppTerminalToolDefProcInfo = kPascalStackBased
  211.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  212.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(TermHandle)))
  213.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  214.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  215.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  216.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  217. };
  218.  
  219. #if GENERATINGCFM
  220. #define NewTerminalSendProc(userRoutine)        \
  221.         (TerminalSendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTerminalSendProcInfo, GetCurrentArchitecture())
  222. #define NewTerminalBreakProc(userRoutine)        \
  223.         (TerminalBreakUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTerminalBreakProcInfo, GetCurrentArchitecture())
  224. #define NewTerminalCacheProc(userRoutine)        \
  225.         (TerminalCacheUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTerminalCacheProcInfo, GetCurrentArchitecture())
  226. #define NewTerminalSearchCallBackProc(userRoutine)        \
  227.         (TerminalSearchCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTerminalSearchCallBackProcInfo, GetCurrentArchitecture())
  228. #define NewTerminalClikLoopProc(userRoutine)        \
  229.         (TerminalClikLoopUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTerminalClikLoopProcInfo, GetCurrentArchitecture())
  230. #define NewTerminalEnvironsProc(userRoutine)        \
  231.         (TerminalEnvironsUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTerminalEnvironsProcInfo, GetCurrentArchitecture())
  232. #define NewTerminalChooseIdleProc(userRoutine)        \
  233.         (TerminalChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTerminalChooseIdleProcInfo, GetCurrentArchitecture())
  234. #define NewTerminalToolDefProc(userRoutine)        \
  235.         (TerminalToolDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTerminalToolDefProcInfo, GetCurrentArchitecture())
  236. #else
  237. #define NewTerminalSendProc(userRoutine)        \
  238.         ((TerminalSendUPP) (userRoutine))
  239. #define NewTerminalBreakProc(userRoutine)        \
  240.         ((TerminalBreakUPP) (userRoutine))
  241. #define NewTerminalCacheProc(userRoutine)        \
  242.         ((TerminalCacheUPP) (userRoutine))
  243. #define NewTerminalSearchCallBackProc(userRoutine)        \
  244.         ((TerminalSearchCallBackUPP) (userRoutine))
  245. #define NewTerminalClikLoopProc(userRoutine)        \
  246.         ((TerminalClikLoopUPP) (userRoutine))
  247. #define NewTerminalEnvironsProc(userRoutine)        \
  248.         ((TerminalEnvironsUPP) (userRoutine))
  249. #define NewTerminalChooseIdleProc(userRoutine)        \
  250.         ((TerminalChooseIdleUPP) (userRoutine))
  251. #define NewTerminalToolDefProc(userRoutine)        \
  252.         ((TerminalToolDefUPP) (userRoutine))
  253. #endif
  254.  
  255. #if GENERATINGCFM
  256. #define CallTerminalSendProc(userRoutine, thePtr, theSize, refCon, flags)        \
  257.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTerminalSendProcInfo, (thePtr), (theSize), (refCon), (flags))
  258. #define CallTerminalBreakProc(userRoutine, duration, refCon)        \
  259.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTerminalBreakProcInfo, (duration), (refCon))
  260. #define CallTerminalCacheProc(userRoutine, refCon, theTermData)        \
  261.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTerminalCacheProcInfo, (refCon), (theTermData))
  262. #define CallTerminalSearchCallBackProc(userRoutine, hTerm, refNum, foundRect)        \
  263.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTerminalSearchCallBackProcInfo, (hTerm), (refNum), (foundRect))
  264. #define CallTerminalClikLoopProc(userRoutine, refCon)        \
  265.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTerminalClikLoopProcInfo, (refCon))
  266. #define CallTerminalEnvironsProc(userRoutine, refCon, theEnvirons)        \
  267.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTerminalEnvironsProcInfo, (refCon), (theEnvirons))
  268. #define CallTerminalChooseIdleProc(userRoutine)        \
  269.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTerminalChooseIdleProcInfo)
  270. #define CallTerminalToolDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  271.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTerminalToolDefProcInfo, (hTerm), (msg), (p1), (p2), (p3))
  272. #else
  273. #define CallTerminalSendProc(userRoutine, thePtr, theSize, refCon, flags)        \
  274.         (*(userRoutine))((thePtr), (theSize), (refCon), (flags))
  275. #define CallTerminalBreakProc(userRoutine, duration, refCon)        \
  276.         (*(userRoutine))((duration), (refCon))
  277. #define CallTerminalCacheProc(userRoutine, refCon, theTermData)        \
  278.         (*(userRoutine))((refCon), (theTermData))
  279. #define CallTerminalSearchCallBackProc(userRoutine, hTerm, refNum, foundRect)        \
  280.         (*(userRoutine))((hTerm), (refNum), (foundRect))
  281. #define CallTerminalClikLoopProc(userRoutine, refCon)        \
  282.         (*(userRoutine))((refCon))
  283. #define CallTerminalEnvironsProc(userRoutine, refCon, theEnvirons)        \
  284.         (*(userRoutine))((refCon), (theEnvirons))
  285. #define CallTerminalChooseIdleProc(userRoutine)        \
  286.         (*(userRoutine))()
  287. #define CallTerminalToolDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  288.         (*(userRoutine))((hTerm), (msg), (p1), (p2), (p3))
  289. #endif
  290. extern pascal TMErr InitTM(void );
  291.  
  292. extern pascal Handle TMGetVersion(TermHandle hTerm);
  293.  
  294. extern pascal short TMGetTMVersion(void );
  295.  
  296. extern pascal TermHandle TMNew(const Rect *termRect, const Rect *viewRect, TMFlags flags, short procID, WindowPtr owner, TerminalSendUPP sendProc, TerminalCacheUPP cacheProc, TerminalBreakUPP breakProc, TerminalClikLoopUPP clikLoop, TerminalEnvironsUPP environsProc, long refCon, long userData);
  297.  
  298. extern pascal void TMDispose(TermHandle hTerm);
  299.  
  300. extern pascal void TMKey(TermHandle hTerm, const EventRecord *theEvent);
  301.  
  302. extern pascal void TMUpdate(TermHandle hTerm, RgnHandle visRgn);
  303.  
  304. extern pascal void TMPaint(TermHandle hTerm, const TermDataBlock *theTermData, const Rect *theRect);
  305.  
  306. extern pascal void TMActivate(TermHandle hTerm, Boolean activate);
  307.  
  308. extern pascal void TMResume(TermHandle hTerm, Boolean resume);
  309.  
  310. extern pascal void TMClick(TermHandle hTerm, const EventRecord *theEvent);
  311.  
  312. extern pascal void TMIdle(TermHandle hTerm);
  313.  
  314. extern pascal long TMStream(TermHandle hTerm, void *theBuffer, long theLength, CMFlags flags);
  315.  
  316. extern pascal Boolean TMMenu(TermHandle hTerm, short menuID, short item);
  317.  
  318. extern pascal void TMReset(TermHandle hTerm);
  319.  
  320. extern pascal void TMClear(TermHandle hTerm);
  321.  
  322. extern pascal void TMResize(TermHandle hTerm, const Rect *newViewRect);
  323.  
  324. extern pascal long TMGetSelect(TermHandle hTerm, Handle theData, ResType *theType);
  325.  
  326. extern pascal void TMGetLine(TermHandle hTerm, short lineNo, TermDataBlock *theTermData);
  327.  
  328. extern pascal void TMSetSelection(TermHandle hTerm, const TMSelection *theSelection, TMSelTypes selType);
  329.  
  330. extern pascal void TMScroll(TermHandle hTerm, short dh, short dv);
  331.  
  332. extern pascal Boolean TMValidate(TermHandle hTerm);
  333.  
  334. extern pascal void TMDefault(Ptr *theConfig, short procID, Boolean allocate);
  335.  
  336. extern pascal Handle TMSetupPreflight(short procID, long *magicCookie);
  337.  
  338. extern pascal void TMSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  339.  
  340. extern pascal Boolean TMSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  341.  
  342. extern pascal void TMSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  343.  
  344. extern pascal void TMSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  345.  
  346. extern pascal void TMSetupPostflight(short procID);
  347.  
  348. extern pascal Ptr TMGetConfig(TermHandle hTerm);
  349.  
  350. extern pascal short TMSetConfig(TermHandle hTerm, const void *thePtr);
  351.  
  352. extern pascal OSErr TMIntlToEnglish(TermHandle hTerm, const void *inputPtr, Ptr *outputPtr, short language);
  353.  
  354. extern pascal OSErr TMEnglishToIntl(TermHandle hTerm, const void *inputPtr, Ptr *outputPtr, short language);
  355.  
  356. extern pascal void TMGetToolName(short id, Str255 name);
  357.  
  358. extern pascal short TMGetProcID(ConstStr255Param name);
  359.  
  360. extern pascal void TMSetRefCon(TermHandle hTerm, long refCon);
  361.  
  362. extern pascal long TMGetRefCon(TermHandle hTerm);
  363.  
  364. extern pascal void TMSetUserData(TermHandle hTerm, long userData);
  365.  
  366. extern pascal long TMGetUserData(TermHandle hTerm);
  367.  
  368. extern pascal short TMAddSearch(TermHandle hTerm, ConstStr255Param theString, const Rect *where, TMSearchTypes searchType, TerminalSearchCallBackUPP callBack);
  369.  
  370. extern pascal void TMRemoveSearch(TermHandle hTerm, short refnum);
  371.  
  372. extern pascal void TMClearSearch(TermHandle hTerm);
  373.  
  374. extern pascal Point TMGetCursor(TermHandle hTerm, TMCursorTypes cursType);
  375.  
  376. extern pascal TMErr TMGetTermEnvirons(TermHandle hTerm, TermEnvironRec *theEnvirons);
  377.  
  378. extern pascal short TMChoose(TermHandle *hTerm, Point where, TerminalChooseIdleUPP idleProc);
  379.  
  380. extern pascal void TMEvent(TermHandle hTerm, const EventRecord *theEvent);
  381.  
  382. extern pascal Boolean TMDoTermKey(TermHandle hTerm, ConstStr255Param theKey);
  383.  
  384. extern pascal short TMCountTermKeys(TermHandle hTerm);
  385.  
  386. extern pascal void TMGetIndTermKey(TermHandle hTerm, short id, Str255 theKey);
  387.  
  388. extern pascal void TMGetErrorString(TermHandle hTerm, short id, Str255 errMsg);
  389.  
  390. #endif
  391.  
  392. #if PRAGMA_ALIGN_SUPPORTED
  393. #pragma options align=reset
  394. #endif
  395.  
  396. #if PRAGMA_IMPORT_SUPPORTED
  397. #pragma import off
  398. #endif
  399.  
  400. #ifdef __cplusplus
  401. }
  402. #endif
  403.  
  404. #endif /* __TERMINALS__ */
  405.  
  406.